package max.ta.download;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Date;

import max.ta.util.conf.SystemConfiguration;

import org.apache.log4j.Logger;

public class YahooDownloader
	implements StockDownloader {

    private static final Logger logger = Logger.getLogger(YahooDownloader.class);
    private final ResourceDownloader downloader = new ResourceDownloader();

    @Override
    public File download(String symbol) throws IOException {
	logger.info(">>> Donwload stock history for " + symbol);
	String rootUrl = SystemConfiguration.getYahooCompleteURL();
	URL url = new URL(rootUrl + symbol);
	String fileName = symbol + ".csv";
	return downloader.downloadFile(url, fileName);
    }

    @Override
    public File download(String symbol, Date startDate) throws IOException {
	return null;
    }

    @Override
    public File download(String symbol, Date startDate, Date endDate) throws IOException {
	return null;
    }
}
